package com.srit.map.web.action;

import org.springframework.beans.factory.annotation.Autowired;

import com.srit.core.struts2.action.CrudAction;
import com.srit.map.business.bean.Role;
import com.srit.map.business.service.RoleService;

/**
 * @author chenxiling
 *
 */
public class RoleAction extends CrudAction {
	
	private Role role=new Role();
	
	@Autowired(required = true)
	private RoleService roleService;
	
	// 简单crud直接交给baseService处理

	// 覆盖父类valiadte，prepare方法，可以进行表单验证
	@Override
	public Object getModel() {
		// TODO Auto-generated method stub
		return role;
	}
	
	public String getRolename(){
		role=roleService.getRoleByUserId(1);
		request.setAttribute("role", role);
		return "success";
	}
	
	public String saveMenu(){
		String menuIdStr=request.getParameter("menuIdList");
		roleService.saveMenuToRole(menuIdStr, role);
		return "save";
	}
	
	public String updateMenu(){
		String menuIdStr=request.getParameter("menuIdList");
		roleService.updateMenuToRole(menuIdStr, role);
		return "update";
	}
	public String json(){
		//List list = 
		return null;
	}
}
